package com.mls.spring.spring_demo.controller;

import com.google.gson.Gson;
import com.mls.spring.spring_demo.data.People;
import com.mls.spring.spring_demo.helper.GsonUtils;
import netscape.javascript.JSObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    @RequestMapping(value = "/world",method = RequestMethod.GET)
    @ResponseBody
    public People hello(@RequestParam(required = false) String a) {
//        String json = GsonUtils.toJson(getPeople());
        return getPeople();
    }

    private People getPeople() {
        People people = new People();
        People.Student student = new People.Student();
        student.setName("xys");
        student.setAge("18");
        student.setSex("female");
        people.student = student;

        People.Programmer programmer = new People.Programmer();
        programmer.setName("mls");
        programmer.setAge("18");
        programmer.setSalary("2");
        people.programmer = programmer;
        return people;
    }


}
